package ee122Networking;

import cern.jet.random.Poisson;
import cern.jet.random.engine.DRand;





public class Client {

	public static void main(String [ ] args)
	{
		boolean secondSender = true, sendImage = true;
		int r = 5;
		int routerPort = 9000;
		int D1port = 4500;
		int D2port = 4501;
		int numPackets = 1000;
		int runs = 1;
		ClientSenderThread s1,s2 = null;
		String imgPath = "/home/qizhu/cat.jpg";
		//String imgPath = "/home/qizhu/Desktop/test";
		//args <interPacketTime, routerAddr, routerPort, numPackets>
		
		// start S1
		if (sendImage)
			s1 = new ClientSenderThread("S1", 2*r, "localhost", routerPort, D1port, imgPath);
		else 
			s1 = new ClientSenderThread("S1", 2*r, "localhost", routerPort, D1port, numPackets);
		s1.start();
		
		// start S2 
		if (secondSender) {
			if (sendImage)
				s2 = new ClientSenderThread("S2", r, "localhost", routerPort, D2port, imgPath);
			else 
				s2 = new ClientSenderThread("S2", r, "localhost", routerPort, D2port, numPackets);
			s2.start();	
		}
		
		// join with S1 and S2 before terminating
		try {
			s1.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		if(secondSender) {
			try {
				s2.join();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	
	}
}
